const app=getApp()
Page({
  
  data: {
    longitude: 113.49473108265684,  //默认定位经度
    latitude: 23.4515213825832,   //默认定位纬度
    bookshelfInfo:[],
    markers: [],
  },
 
  async onLoad() {
    var that = this;
    const markers=await wx.p.request({
      url:app.globalData.url+"/login/getlocallist",
      method:"GET"
    })
    this.setData({
      bookshelfInfo:markers.data.data
    })
    var arr=[]
    for (let i = 0; i < this.data.bookshelfInfo.length; i++) {
      let newObj = {
        id: i + 1,
        latitude: Number(that.data.bookshelfInfo[i].shelflatitude),
        longitude: Number(that.data.bookshelfInfo[i].shelflongitude),
        width: 20,
        height: 20
      };
      arr.push(newObj);
    }
    this.setData({
      markers:arr
    })
    
    const getlocal=await wx.p.getLocation({
      type: "wgs84",
    })
    // this.setData({
    //   latitude:getlocal.latitude,
    //   longitude:getlocal.longitude
    // })
    // {
    //   var latitude = res.latitude;
    //   var longitude = res.longitude;
    //   //console.log(res.latitude);
    //   that.setData({
    //     latitude: res.latitude,
    //     longitude: res.longitude,
    //     markers: this.data.markers
    //   })
    // }
  },
  onReady: function () {
 
  }
})